Skip to content

Fix link parsing to terminate properly#2091

Merged
patriksvensson merged 2 commits intospectreconsole:mainfrom
zhuman:zhuman/fix_links
Apr 16, 2026
Merged

Fix link parsing to terminate properly#2091
patriksvensson merged 2 commits intospectreconsole:mainfrom
zhuman:zhuman/fix_links

Conversation

@zhuman
Copy link
Copy Markdown
Contributor

@zhuman zhuman commented Apr 16, 2026

Fixes #2090

  • I have read the Contribution Guidelines
  • I have checked that there isn't already another pull request that solves the above issue
  • All newly added code is adequately covered by tests
  • All existing tests are still running without errors

I used GitHub Copilot to generate the new tests.

Changes

This change is pretty straightforward - it promotes links to be treated similarly to styles in the markup parser, where they are parsed out of new tags and pushed into a stack. Closing the tag caused them to get popped from the stack. The AnsiMarkupSegments comparison that is used to merge together text of the same style now compares the active link.

Three new tests were added to SelectionPrompt confirming that links embedded in SelectionPrompts don't exhibit the incorrect behavior (this is where I originally noticed the issues). Two new tests were added to AnsiConsoleTests.Markup to validate that nesting and link closure works.


Please upvote 👍 this pull request if you are interested in it.

@zhuman zhuman changed the title Zhuman/fix links Fix links in markup Apr 16, 2026
@zhuman zhuman changed the title Fix links in markup Fix link parsing to terminate properly Apr 16, 2026
@patriksvensson patriksvensson merged commit 270afc3 into spectreconsole:main Apr 16, 2026
3 checks passed
@patriksvensson
Copy link
Copy Markdown
Contributor

Merged! Thank you for your contribution. Much appreciated! 👍

This was referenced Apr 16, 2026
This was referenced Apr 22, 2026
microsoft-github-policy-service Bot pushed a commit to Azure/bicep that referenced this pull request Apr 24, 2026
Updated
[Spectre.Console](https://github.com/spectreconsole/spectre.console)
from 0.54.0 to 0.55.2.

<details>
<summary>Release notes</summary>

_Sourced from [Spectre.Console's
releases](https://github.com/spectreconsole/spectre.console/releases)._

## 0.55.2

## What's Changed

* Support variation selectors, ZWJ sequences and surrogate pairs in
length calculation by @​fabsenet in
spectreconsole/spectre.console#2082
* Add default value to selection prompt and multiselection prompt by
@​AntekOlszewski in
spectreconsole/spectre.console#2079

## New Contributors
* @​fabsenet made their first contribution in
spectreconsole/spectre.console#2082

**Full Changelog**:
spectreconsole/spectre.console@0.55.1...0.55.2

## 0.55.1

## What's Changed

* Add tests to verify public API by @​patriksvensson in
spectreconsole/spectre.console#2073
* use StringComparer.OrdinalIgnoreCase as default comparer for
TextPrompt by @​AntekOlszewski in
spectreconsole/spectre.console#2077
* Fix markup link rendering regression by @​patriksvensson in
spectreconsole/spectre.console#2084
* Add VS16 suffix to non-presentation emojis by @​patriksvensson in
spectreconsole/spectre.console#2087
* Ensure rendered exceptions take up minimal space by @​patriksvensson
in spectreconsole/spectre.console#2089
* Fix link parsing to terminate properly by @​zhuman in
spectreconsole/spectre.console#2091

## New Contributors
* @​zhuman made their first contribution in
spectreconsole/spectre.console#2091

**Full Changelog**:
spectreconsole/spectre.console@0.55.0...0.55.1

## 0.55.0

This release brings new features, performance improvements, bug fixes,
and some important architectural changes.

> [!CAUTION]
> There are breaking changes in this release, so make sure you review
the release notes and try things out before upgrading in production.

## New Spectre.Console.Ansi Library

One of the biggest changes in this release is the introduction of 

[Spectre.Console.Ansi](https://www.nuget.org/packages/spectre.console.ansi),
a new standalone library for writing ANSI escape
sequences to the terminal without taking a full dependency on
`Spectre.Console`.

This makes it easy to add ANSI support to lightweight tools and
libraries where
pulling in the full Spectre.Console package would be overkill.
Spectre.Console
itself now depends on this library internally.

We've also added some nice convenience methods for the .NET Console
class:

```csharp
using Spectre.Console.Ansi;

Console.Markup("[yellow]Hello[/] ");
Console.MarkupLine("[blue]World[/]");
  
Console.Ansi(writer => writer
    .BeginLink("https://spectreconsole.net", linkId: 123)
    .Decoration(Decoration.Bold | Decoration.Italic)
    .Foreground(Color.Yellow)
    .Write("Spectre Console")
    .ResetStyle()
    .EndLink());
```

## Style Is Now a Struct

`Style` has been converted from a class to a struct, and link/URL
information
has been extracted into a separate `Link` type. This improves allocation
performance, especially in rendering-heavy scenarios, but is a breaking
change
for code that relies on reference semantics.

## Progress Improvements

The `Progress` widget received a lot of love in this release. It now
uses
`TimeProvider` instead of the wall clock, making it significantly easier
to
write deterministic tests. `ProgressTask` has a new `Tag` property for
attaching
arbitrary metadata, and you can now override the global
hide-when-completed
behavior on individual tasks. Tasks can also be removed from the
progress
context entirely.

Speed calculations have been improved with configurable max sampling age
and
 ... (truncated)

Commits viewable in [compare
view](spectreconsole/spectre.console@0.54.0...0.55.2).
</details>

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=Spectre.Console&package-manager=nuget&previous-version=0.54.0&new-version=0.55.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>
###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/19497)

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Links do not terminate properly and multiple links per markup block don't work

2 participants